import yaml

# 有个现象需要留意: 当文件取名'yaml.py'则无法跑, 因为此时import yaml加载的是本yaml.py
def load_cfg(file_path):
    with open(file_path, 'r') as f:
        conf = yaml.load(f)
        # old_plus.host old_plus.user old_plus.password  old_plus.port
        source_conf = conf.get('old_plus')
        HOST_SRC = source_conf['host']
        USER_SRC = source_conf['user']
        PASSWORD_SRC = str(source_conf['password'])
        PORT_SRC = source_conf['port']
        # new_plus.host new_plus.user new_plus.password  new_plus.port
        target_conf = conf.get('new_plus')
        HOST_DST = target_conf['host']
        USER_DST = target_conf['user']
        PASSWORD_DST = str(target_conf['password'])
        PORT_DST = target_conf['port']
        print(PORT_DST)


if __name__ == '__main__':
    load_cfg('conf.yaml')
